﻿using NUnit.Framework;
using MineSweeper;

namespace MineSweeper.Test
{
    [TestFixture]
    public class TestingMineSweeper

    {
        private string[] startfeld;

        [Test]
        public void CheckMogelZettelResult0()
        {
            string[] result = Transformer.Mogelzettel(startfeld);
            Assert.That(result[0], Is.EqualTo("011312"));
        }

        [Test]
        public void CheckMogelZettelResult1()
        {
            string[] result = Transformer.Mogelzettel(startfeld);
            Assert.That(result[1], Is.EqualTo("121422"));
        }

        [Test]
        public void CheckMogelZettelResult2()
        {
            string[] result = Transformer.Mogelzettel(startfeld);
            Assert.That(result[2], Is.EqualTo("022232"));
        }

        [Test]
        public void CheckMogelZettelResult3()
        {
            string[] result = Transformer.Mogelzettel(startfeld);
            Assert.That(result[3], Is.EqualTo("233220"));
        }

        [Test]
        public void CheckMogelZettelResult4()
        {
            string[] result = Transformer.Mogelzettel(startfeld);
            Assert.That(result[4], Is.EqualTo("111111"));
        }

        [Test]
        public void CheckCompleteFirstRow()
        {
            bool[,] minenfeldBoolArray = Transformer.TransformMinenfeldIntoBoolArray(startfeld);
            int[,] numberOfMines =
                Transformer.TransformMinenfeldBoolArrayToCircleIntArray(
                    minenfeldBoolArray);
            string[] result = Transformer.TransformIntoStringArray(numberOfMines);
            Assert.That(result[0], Is.EqualTo("011312"));
        }

        [Test]
        public void TransformMinenfeldIntoBoolArrayResultLength()
        {
            bool[,] erweitertesMinenfeld = Transformer.TransformMinenfeldIntoBoolArray(startfeld);
            Assert.That(erweitertesMinenfeld.Length, Is.EqualTo((6 + 2)*(5+2)));
        }

        [Test]
        public  void CheckBoolValueForCoordinate_0_4()
        {
            bool[,] erweitertesMinenfeld = Transformer.TransformMinenfeldIntoBoolArray(startfeld);
            Assert.That(erweitertesMinenfeld[0+1,4+1], Is.True);
        }

        [Test]
        public void CheckIntValueForCoordinate_0_2()
        {
            bool[,] minenfeldBoolArray = Transformer.TransformMinenfeldIntoBoolArray(startfeld);
            int[,] numberOfMines =
                Transformer.TransformMinenfeldBoolArrayToCircleIntArray(
                    minenfeldBoolArray);
            Assert.That(numberOfMines[0+1,2+1], Is.EqualTo(1));
        }

        [Test]
        public void CheckIntValueForCoordinate_0_1()
        {
            bool[,] minenfeldBoolArray = Transformer.TransformMinenfeldIntoBoolArray(startfeld);
            int[,] numberOfMines =
                Transformer.TransformMinenfeldBoolArrayToCircleIntArray(
                    minenfeldBoolArray);
            Assert.That(numberOfMines[0 + 1, 1 + 1], Is.EqualTo(1));
        }

        [Test]
        public void CheckIntValueForCoordinate_1_3()
        {
            bool[,] minenfeldBoolArray = Transformer.TransformMinenfeldIntoBoolArray(startfeld);
            int[,] numberOfMines =
                Transformer.TransformMinenfeldBoolArrayToCircleIntArray(
                    minenfeldBoolArray);
            Assert.That(numberOfMines[1 + 1, 3 + 1], Is.EqualTo(4));
        }

        [SetUp]
        public void Setup()
        {
            startfeld = new string[] {"----*-", "--*-*-", "*--*--", "-----*","-**---"};
        }
    }
}
